package com.rpp.study.hystrix;

import com.rpp.study.base.LagouResponse;
import com.rpp.study.feign.FeignCode;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @Description
 * @Author rpp
 * @Date 2020/8/28 10:40 下午
 */
@Slf4j
@Component
public class HystrixCodeFactory implements FallbackFactory<FeignCode> {
    @Override
    public FeignCode create(Throwable throwable) {
        log.error("触发熔断：", throwable);
        return new FeignCode() {
            @Override
            public LagouResponse<Boolean> create(String email) {
                return LagouResponse.error();
            }

            @Override
            public LagouResponse<Integer> validate(String email, String code) {
                return LagouResponse.error();
            }
        };
    }
}
